package com.zd.service.impl;

import com.github.pagehelper.PageHelper;
import com.zd.mapper.PracticeManageInfoMapper;
import com.zd.model.PracticeStatistics;
import com.zd.model.WorkInfoStatistics;
import com.zd.model.PracticeManageInfo;
import com.zd.service.IPracticeManageInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class PracticeManageInfoServiceImpl implements IPracticeManageInfoService {

    @Autowired
    private PracticeManageInfoMapper practiceManageInfoMapper;

    @Override
    public List<PracticeManageInfo> selectPracticeManageInfo(int pageNum, int pageSize, Map<String, Object> queryMap) {
        PageHelper.startPage(pageNum, pageSize);

        List<PracticeManageInfo> practiceManageInfoList = practiceManageInfoMapper.selectPracticeManageInfo(queryMap);

        return practiceManageInfoList;
    }

    @Override
    public boolean insertSelective(PracticeManageInfo record) {

        practiceManageInfoMapper.insertSelective(record);

        return true;
    }



    @Override
    public List<PracticeStatistics> selectPracticeStatistics(Map<String, Object> statisticsMap) {
        List<PracticeStatistics> practiceStatisticsList=practiceManageInfoMapper.selectPracticeStatistics(statisticsMap);
        return practiceStatisticsList;
    }

    @Override
    public PracticeManageInfo selectPracticeManageInfoById(int id) {
        Map<String, Object> queryMap = new HashMap<String, Object>();
        queryMap.put("id", id);
        PracticeManageInfo info = practiceManageInfoMapper.selectPracticeManageInfo(queryMap).get(0);
        return info;
    }

    @Override
    public boolean updateSelective(PracticeManageInfo practiceManageInfo) {
        practiceManageInfoMapper.updateByPrimaryKeySelective(practiceManageInfo);
        return true;
    }

    @Override
    public boolean deletePracticeManageInfo(int id) {
        PracticeManageInfo practiceManageInfo=new PracticeManageInfo();

        practiceManageInfo.setId(new Long(id));

        practiceManageInfo.setFlag(0);

        practiceManageInfoMapper.updateByPrimaryKeySelective(practiceManageInfo);

        return true;
    }

    @Override
    public List<PracticeManageInfo> selectPracticeManageExport(Map<String, Object> queryMap) {

        List<PracticeManageInfo> practiceManageInfoList = practiceManageInfoMapper.selectPracticeManageInfo(queryMap);

        return practiceManageInfoList;
    }
}
